# include <cstdio>
# include <cstring>
# include <iostream>
# include <algorithm>
using namespace std;

# define testin freopen("in.txt", "r", stdin)
# define testout freopen("out.txt", "w", stdout)

# define rep(x) for(int i = 0; i < (x); ++i)
# define clr(x) memset(x, 0, sizeof(x))
# define clrc(x, c) memset(x, 0, (c)*sizeof(x[0]))

typedef unsigned long long int ulli;
typedef long long int lli;

int np;
int p[10005];
bool isP[10005];

bool isPrime(int x)
{
    if (x < 2) return false;
    for (int i = 2; i*i <= x; ++i) {
        if (x%i == 0) return false;
    }
    return true;
}

int f[4000005], nf;
int x[4000005], y[4000005], r[4000005];
bool cmp(const int a, const int b)
{
    return f[ a ] < f[ b ] ? true : false;
}
int main()
{
    clr(isP);
    np = 0;
    for (int i = 0; i < 10005; ++i) {
        if (isPrime(i)) p[np++] = i, isP[i] = true;
    }
    nf = 0;
    rep(np) for (int j = i; j < np; ++j) {
        r[nf] = nf;
        f[nf] = p[i]+p[j];
        x[nf] = p[i];
        y[nf] = p[j];
        nf ++;
    }
    sort(r, r+nf, cmp);

    int xx;
    while (cin >> xx) {
        int ans = 0;
        rep(nf) {
            int t = r[i];
            if (f[t] >= xx) break;
            if (isP[xx-f[t]] && (xx-f[t])>=x[t] && (xx-f[t])>=y[t]) {
                ++ans;
            }
        }
        cout << ans << endl;
    }

    return 0;
}
